<template>
  <div class="right-top-content">
    <div class="top-num m-t-12">
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            用户总量
            <div class="n-c-num">1600</div>
          </div>
        </div>
      </div>
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            当前在线
            <div class="n-c-num">205</div>
          </div>
        </div>
      </div>
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            今日新增
            <div class="n-c-num">20</div>
          </div>
        </div>
      </div>
    </div>
    <div class="user m-t-40">
      <!-- 用户增长趋势 -->
      <div class="user-increase">
        <v-chart class="chart" :option="user_increase_option" />
      </div>
      <!-- 用户登录趋势 -->
      <div class="user-increase">
        <v-chart class="chart" :option="user_login_option" />
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { generateDateLabels} from "@/utils/publicMethod";
// 用户增长趋势
const user_increase_option = ref({
  title: {
    text: '用户增长趋势（近30天）',
    left: 'center',
      textStyle: {
          color: '#D3D6DD',
          fontSize: 16,
      }
  },
  tooltip: {
      trigger: 'axis',
      axisPointer: {
          type: 'shadow'
      },
      formatter: '{b}:{c}人'
  },
  xAxis: {
    type: 'category',
    data: generateDateLabels(),
    axisLine: {
      lineStyle: {
        color: '#D3D6DD'
      }
    },
    axisLabel: {
      color: '#D3D6DD'
    }
  },
  yAxis: {
    type: 'value',
    // name: '人',
    nameTextStyle: {
      color: '#D3D6DD',
      padding: [0, 0, 0, 30] // 调整单位位置
    },
    axisLine: {
      lineStyle: {
        color: '#D3D6DD',
        show: true
      }
    },
    axisLabel: {
      color: '#D3D6DD',
      formatter: '{value}' // 可以自定义格式，这里保持原样
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(211, 214, 221, 0.2)' // 浅色分割线
      }
    }
  },
  series: [
    {
      data: [2, 3, 4, 5, 6, 7, 8, 9, 9, 10,
        10, 11, 3, 13, 13, 14, 15, 13, 16, 17,
        17, 19, 18, 19, 6, 19, 20, 20, 13, 20],
      type: 'line',
      smooth: true,
      lineStyle: {
        color: '#5B8FF9', // 线条颜色
        width: 3
      },
      symbol: 'circle', // 数据点形状
      symbolSize: 8,
      itemStyle: {
        color: '#5B8FF9' // 数据点颜色
      },
    }
  ],
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    top: '15%',
    containLabel: true
  }
})
// 用户登录趋势
const user_login_option = ref({
  title: {
    text: '用户登录趋势（近30天）',
    left: 'center',
      textStyle: {
          color: '#D3D6DD',
          fontSize: 16,
      }
  },
  tooltip: {
      trigger: 'axis',
      axisPointer: {
          type: 'shadow'
      },
      formatter: '{b}:{c}人'
  },
  xAxis: {
    type: 'category',
    data: generateDateLabels(),
    axisLine: {
      lineStyle: {
        color: '#D3D6DD'
      }
    },
    axisLabel: {
      color: '#D3D6DD'
    }
  },
  yAxis: {
    type: 'value',
    // name: '人',
    nameTextStyle: {
      color: '#D3D6DD',
      padding: [0, 0, 0, 30] // 调整单位位置
    },
    axisLine: {
      lineStyle: {
        color: '#D3D6DD',
        show: true
      }
    },
    axisLabel: {
      color: '#D3D6DD',
      formatter: '{value}' // 可以自定义格式，这里保持原样
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(211, 214, 221, 0.2)' // 浅色分割线
      }
    }
  },
  series: [
    {
      data: [142, 278, 195, 103, 256, 189, 221, 134, 267, 112,
 203, 245, 176, 298, 123, 231, 154, 287, 165, 209,
 132, 276, 198, 114, 253, 187, 224, 139, 261, 304],
      type: 'line',
      smooth: true,
      lineStyle: {
        color: '#5B8FF9', // 线条颜色
        width: 3
      },
      symbol: 'circle', // 数据点形状
      symbolSize: 8,
      itemStyle: {
        color: '#5B8FF9' // 数据点颜色
      },
    }
  ],
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    top: '15%',
    containLabel: true
  }
})
</script>
<style scoped lang="scss">
.right-top-content {
  width: 100%;
  height: 100%;
  .cont-title {
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: bold;
  }
  .top-num {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    .top-num-cont {
      width: calc(100% / 3 - 10px);
      display: flex;

      .top-num-cont-img {
        width: 35%;
        height: 100%;
        margin-right: 5%;
        background-image: url("@/assets/img/left_top_huang.png");
      }
      .top-num-cont-right {
        flex: 1;
        .n-c-title {
          font-size: 14px;
        }
        .n-c-num {
          font-size: 20px;
          font-weight: bold;
        }
      }
    }
  }
  .user {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    .user-increase {
      width: calc(100% / 2 - 10px);
      height: 210px;
    }
  }
}
</style>